package com.example.Arithmetic.Lettcode;

/**
 * 日期：2024/1/2
 * 时间：13:11
 * 描述：x的平方根
 */
public class E01Lettcode69 {
    public int mySqrt(int x) {
        int i = 1, j = x;
        int r = 0;
        while (i <= j) {
            int m = (i + j) >>> 1;
            if (x / m >= m) {
                r = m;
                i = m+1;
            } else {
                j = m-1;
            }
        }
        return r;
    }
}

